
package com.jf.cloud.service.sysmanager.remote;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.jf.cloud.service.sysmanager.common.base.AjaxPageData;
import com.jf.cloud.service.sysmanager.common.base.OPaging;
import com.jf.cloud.service.sysmanager.dao.IPubgBasePropsConfigService;
import com.jf.cloud.service.sysmanager.entity.PubgBasePropsConfig;
import com.jf.cloud.service.sysmanager.support.web.BaseController;

/**
 * 基础属性配置控制器
 * 
 * @author 绝峰代码机1.0 创建时间：2018-03-31
 */
@Controller
@RequestMapping("/pubgBasePropsConfig.do")
public class PubgBasePropsConfigController extends BaseController {

	/**
	 * 日志
	 */
	private static Log log = LogFactory.getLog(PubgBasePropsConfigController.class);

	/**
	 * 基础属性配置服务
	 */
	@Resource
	private IPubgBasePropsConfigService pubgBasePropsConfigService;

	/**
	 * 基础属性配置列表页面
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	@RequestMapping(params = "method=listPubgBasePropsConfig")
	public AjaxPageData<PubgBasePropsConfig> listPubgBasePropsConfig(OPaging<PubgBasePropsConfig> page, HttpServletRequest request) {
		AjaxPageData<PubgBasePropsConfig> dataPage = new AjaxPageData<PubgBasePropsConfig>();
		try {
			dataPage = getAjaxPageData(pubgBasePropsConfigService.findPage(page));
		} catch (Exception e) {
			log.error("获取基础属性配置列表页面出错！", e);
		}
		return dataPage;
	}

	/**
	 * 基础属性配置新增页面
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	@RequestMapping(params = "method=toAddPubgBasePropsConfig")
	public ModelAndView toAddPubgBasePropsConfig() {
		ModelAndView mv = new ModelAndView();
		try {
			PubgBasePropsConfig pubgBasePropsConfig = new PubgBasePropsConfig();
			mv.addObject("pubgBasePropsConfig", pubgBasePropsConfig);

			mv.setViewName("/pubgBasePropsConfigEdit");
		} catch (Exception e) {
			log.error("获取基础属性配置新增页面出错！", e);
			mv.setViewName("../exception");
		}
		return mv;
	}

	/**
	 * 新增基础属性配置
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	@RequestMapping(params = "method=addPubgBasePropsConfig")
	public String addPubgBasePropsConfig(PubgBasePropsConfig pubgBasePropsConfig, HttpServletRequest request) {
		String errCode = "&errCode=1";
		try {
			this.pubgBasePropsConfigService.saveOrUpdatePubgBasePropsConfig(pubgBasePropsConfig);
		} catch (Exception e) {
			errCode = "&errCode=-1";
			log.error("新增基础属性配置出错！", e);
		}
		return "redirect:pubgBasePropsConfig.do?method=listPubgBasePropsConfig" + errCode;
	}

	/**
	 * 基础属性配置修改页面
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	@RequestMapping(params = "method=toUpdatePubgBasePropsConfig")
	public ModelAndView toUpdatePubgBasePropsConfig(Long rowId, HttpServletRequest request) {
		ModelAndView mv = new ModelAndView();
		try {
			PubgBasePropsConfig pubgBasePropsConfig = pubgBasePropsConfigService.findPubgBasePropsConfig(rowId);
			mv.addObject("pubgBasePropsConfig", pubgBasePropsConfig);

			mv.setViewName("/pubgBasePropsConfigEdit");
		} catch (Exception e) {
			log.error("获取基础属性配置修改页面出错！", e);
			mv.setViewName("../exception");
		}
		return mv;
	}

	/**
	 * 修改基础属性配置
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	@RequestMapping(params = "method=updatePubgBasePropsConfig")
	public String updatePubgBasePropsConfig(PubgBasePropsConfig pubgBasePropsConfig, HttpServletRequest request) {
		String errCode = "&errCode=2";
		try {
			this.pubgBasePropsConfigService.saveOrUpdatePubgBasePropsConfig(pubgBasePropsConfig);
		} catch (Exception e) {
			errCode = "&errCode=-2";
			log.error("修改基础属性配置出错！", e);
		}
		return "redirect:pubgBasePropsConfig.do?method=listPubgBasePropsConfig" + errCode;
	}

	/**
	 * 基础属性配置查看页面
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	@RequestMapping(params = "method=toViewPubgBasePropsConfig")
	public ModelAndView toViewPubgBasePropsConfig(Long rowId, HttpServletRequest request) {
		ModelAndView mv = new ModelAndView();
		try {
			PubgBasePropsConfig pubgBasePropsConfig = pubgBasePropsConfigService.findPubgBasePropsConfig(rowId);
			mv.addObject("pubgBasePropsConfig", pubgBasePropsConfig);

			mv.setViewName("/pubgBasePropsConfigView");
		} catch (Exception e) {
			log.error("获取基础属性配置查看页面出错！", e);
			mv.setViewName("../exception");
		}
		return mv;
	}

}
